package api

import (
	"context"
	"doctor_srv/model/dao"
	pb "doctor_srv/proto"
	"errors"
)

type DoctorServer struct {
	pb.UnimplementedDoctorServer
}

func (d *DoctorServer) Login(ctx context.Context, req *pb.LoginRequest) (resp *pb.LoginResponse, err error) {

	account, err := dao.GetDoctorByAccount(req.Account)
	if err != nil {
		return nil, err
	}
	if account.Pwd != req.Pwd {
		return nil, errors.New("密码错误")
	}

	return &pb.LoginResponse{
		Success: true,
		UserId:  int32(account.ID),
	}, nil
}
